@extends('layouts.console_header')

@section('title', '举报评价列表')

@section('resources')
    @parent
    <style>
        .user_list_search{overflow: hidden;margin: 10px 20px;}
        .user_list_search span{float: left;color: #808080;}
        .user_list_search input{float: right;width: 200px;height: 30px;border: 1px solid #000;}
        .user_list_search .user_list_searchbtn{float: right;height: 30px;margin-left: 10px;width: 50px;background-color: #9955c6;color: #fff;border: none;}
        .user_list_pageouter{overflow: hidden;background-color: #fff;}
        .user_list_page{float: right;overflow: hidden;}
        .user_list_page a{float: left;width: 40px;height: 30px;line-height: 30px;text-align: center;}
        .user_list_page .show{background-color: #eee;border: 1px solid #ccc;}
        .display{text-align: center;background-color: #fff;border-collapse:collapse;}
        .display th{padding: 20px 0;}
        .display #tbody_content{border-top: 1px solid #000;border-bottom: 1px solid #000;font-size: 14px;}
        .display #tbody_content tr:nth-child(2n+1){border-bottom: 1px solid #ddd;background-color: #f9f9f9;}
        .display #tbody_content tr:nth-child(2n){border-bottom: 1px solid #ddd;}
        .display #tbody_content tr td{padding: 10px;}
        .display #tbody_content tr td:nth-child(1){background-color: #f1f1f1;}
        nav{height: 50px;line-height: 50px;}
        nav a,nav span{margin-left: 20px;}
        nav input{margin-left: 20px;height: 28px;border: 1px solid #000;margin-top: 10px;}
        button{cursor: pointer;}
    </style>
@endsection

@section('content')
<section class="user_list">
    <p class="fz_14 account_title">
        <span style="color: #7f7f7f;"><a href="/console/index">首页</a>>订单管理></span>
        <span class="co_violet">举报评价列表</span>
    </p>
    <nav>
        <a class="fl" href="/console/order/report/list?cityid={{$cityid}}&type=today">今日</a>
        <a class="fl" href="/console/order/report/list?cityid={{$cityid}}&type=yesterday">昨日</a>
        <a class="fl" href="/console/order/report/list?cityid={{$cityid}}&type=week">本周</a>
        <a class="fl" href="/console/order/report/list?cityid={{$cityid}}&type=thismonth">本月</a>
        <a class="fl" href="/console/order/report/list?cityid={{$cityid}}&type=lastmonth">上月</a>
        <a class="fl" href="/console/order/report/list?cityid={{$cityid}}&type=all">全部</a>
        <span class="fl">时段选择</span>
        <input class="fl" type="date" name="starttime" value="{{date('Y-m-d', strtotime($starttime))}}" onchange="select_date()">
        <span class="fl">至</span>
        <input class="fl" type="date" name="lasttime" value="{{date('Y-m-d', strtotime($lasttime))}}" onchange="select_date()">
    </nav>
    <p class="user_list_search">
        <span>合计：{{$total}}条举报记录（{{$waittotal}}条待处理，{{$reportinvalidtotal}}条举报无效，{{$deletetotal}}条已删除）</span>
        <input class="user_list_searchbtn" type="button" name="submit_search" value="搜索">
        <input type="text" name="search" value="" placeholder="搜索">
    </p>
    <table class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th style="width: 40px;">序号</th>
                <th>举报时间</th>
                <th>订单号</th>
                <th>用户昵称</th>
                <th>用户账号</th>
                <th>门店名称</th>
                <th style="width: 70px;">举报理由</th>
                <th>评分</th>
                <th>评价内容</th>
                <th style="width: 70px;">处理状态</th>
                <th style="width: 50px;">处理人</th>
                <th>处理时间</th>
                <th style="width: 120px;">操作</th>
            </tr>
        </thead>
        <tfoot>
            <tr>
                <th>序号</th>
                <th>举报时间</th>
                <th>订单号</th>
                <th>用户昵称</th>
                <th>用户账号</th>
                <th>门店名称</th>
                <th>举报理由</th>
                <th>评分</th>
                <th>评价内容</th>
                <th>处理状态</th>
                <th>处理人</th>
                <th>处理时间</th>
                <th style="width: 120px;">操作</th>
            </tr>
        </tfoot>
        <tbody id="tbody_content">
            @foreach($lists as $list)
                <tr>
                @if(!isset($i))
                    <td>{{$i=($page-1)*$perpage+1}}</td>
                @else
                    <td>{{++$i}}</td>
                @endif
                    {{--<td>{{$list['commentid']}}</td>--}}
                    <td>{{date('Y-m-d H:i', strtotime($list['reporttime']))}}</td>
                    <td>{{$list['ordernumber']}}</td>
                    <td>{{$list['nickname']}}</td>
                    <td>{{$list['mobile']}}</td>
                    <td>{{$list['shopname']}}</td>
                    <td>{{$list['reportcontent']}}</td>
                    <td>{{$list['score']}}</td>
                    <td>{{$list['content']}}</td>
                     <!-- 举报状态0未举报1已举报2不处理3已删除 -->
                @if($list['reportstatus'] == '0')
                    <td>未举报</td>
                @elseif($list['reportstatus'] == '1')
                    <td>待处理</td>
                @elseif($list['reportstatus'] == '2')
                    <td>举报无效</td>
                @elseif($list['reportstatus'] == '3')
                    <td>已删除</td>
                @else
                    <td></td>
                @endif
                    <td>{{$list['adminname']}}</td>
                    <td>{{date('Y-m-d H:i', strtotime($list['updated_at']))}}</td>
                    <td style="width: 90px;">
                    @if($list['reportstatus'] == '1')
                        <a class="no_deal_with_btn" style="margin-right: 10px;" href="#" onclick="report_invalid('{{$list['commentid']}}')">举报无效</a>
                        <a class="delete_btn co_red" href="#" onclick="delete_report('{{$list['commentid']}}')">删除</a>
                    @elseif($list['reportstatus'] == '3')

                    @else
                        <span style="margin-right: 10px;color: #808080;">举报无效</span>
                    @endif
                    </td>
                </tr>
            @endforeach
        </tbody>
    </table>

    <div class="user_list_pageouter">
        <p class="user_list_page">
            <a href="/console/order/report/list?cityid={{$cityid}}&page=1&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">首页</a>
            @if($lastpage <=5)
                @for($i=1; $i<=$lastpage; $i++)
                    @if($page == $i)
                        <a href="/console/order/report/list?cityid={{$cityid}}&page={{$i}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}" class="show">{{$i}}</a>
                    @else
                        <a href="/console/order/report/list?cityid={{$cityid}}&page={{$i}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$i}}</a>
                    @endif
                @endfor
            @else
                @if($page>2)
                    <a href="/console/order/report/list?cityid={{$cityid}}&page={{$page-2}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page-2}}</a>
                @endif
                @if($page>1)
                    <a href="/console/order/report/list?cityid={{$cityid}}&page={{$page-1}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page-1}}</a>
                @endif
                <a href="/console/order/report/list?cityid={{$cityid}}&page={{$page}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}" class="show">{{$page}}</a>
                @if(($page+5)<$lastpage)
                    <a href="/console/order/report/list?cityid={{$cityid}}&page={{$page+1}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+1}}</a>
                    <a href="/console/order/report/list?cityid={{$cityid}}&page={{$page+2}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+2}}</a>
                    <a href="/console/order/report/list?cityid={{$cityid}}&page={{$page+3}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+3}}</a>
                    <a href="/console/order/report/list?cityid={{$cityid}}&page={{$page+4}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+4}}</a>
                    <a href="">....</a>
                    <a href="/console/order/report/list?cityid={{$cityid}}&page={{$lastpage}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$lastpage}}</a>
                @else
                    @for($i=1; $i<=5;$i++)
                        @if($page+$i<=$lastpage)
                            <a href="/console/order/report/list?cityid={{$cityid}}&page={{$page+$i}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">{{$page+$i}}</a>
                        @endif
                    @endfor
                @endif
            @endif
            <a href="/console/order/report/list?cityid={{$cityid}}&page={{$lastpage}}&starttime={{date('Y-m-d', strtotime($starttime))}}&lasttime={{date('Y-m-d', strtotime($lasttime))}}&search={{$search}}">末页</a>
        </p>
    </div>
</section>
<ul class="delete delete_report">
    <li>
        <span>确认</span>
        <img class="fr" src="{{env('IMAGE_DOMAIN')}}images/close_p.png" alt="">
    </li>
    <li>确定删除评论内容么？</li>
    <li>
        <input type="hidden" name="commentid" value="">
        <button style="background-color: #9955c6;color: #fff;" class="fl delete_sure">确定</button>
        <button class="fr delete_center">取消</button>
    </li>
</ul>
<ul class="delete no_deal_with">
    <li>
        <span>确认</span>
        <img class="fr" src="{{env('IMAGE_DOMAIN')}}images/close_p.png" alt="">
    </li>
    <li>确定对该评价内容做“举报无效”处理么？</li>
    <li>
        <input type="hidden" name="commentid" value="">
        <button style="background-color: #9955c6;color: #fff;" class="fl no_deal_with_sure">确定</button>
        <button class="fr no_deal_with_center">取消</button>
    </li>
</ul>
@endsection

@section('scriptResources')
    @parent
<script>
    var cityid='{{$cityid}}';
    var starttime='{{$starttime}}';
    var lasttime='{{$lasttime}}';
    var str = window.location.href;
    if(str.indexOf("today") > 0){
        $("nav a").eq(0).css({"color": "#9955c6"});
    }else if(str.indexOf("yesterday") > 0){
        $("nav a").eq(1).css({"color": "#9955c6"});
    }else if(str.indexOf("week") > 0){
        $("nav a").eq(2).css({"color": "#9955c6"});
    }else if(str.indexOf("thismonth") > 0){
        $("nav a").eq(3).css({"color": "#9955c6"});
    }else if(str.indexOf("lastmonth") > 0){
        $("nav a").eq(4).css({"color": "#9955c6"});
    }else if(str.indexOf("all") > 0){
        $("nav a").eq(5).css({"color": "#9955c6"});
    }
    function delete_report(comment_id){
        $(".delete_report input[name='commentid']").val(comment_id);
        $(".delete_report").show();
    }
    //举报无效
    function report_invalid(comment_id) {
        $(".no_deal_with input[name='commentid']").val(comment_id);
        $(".no_deal_with").show();
    }
    $(".delete_report li img").click(function(){
        $(".delete_report").hide();
    })
    $(".delete_center").click(function(){
        $(".delete_report").hide();
    })
    $(".no_deal_with li img").click(function(){
        $(".no_deal_with").hide();
    })
    $(".no_deal_with_center").click(function(){
        $(".no_deal_with").hide();
    })
    //删除评论
    $(".delete_sure").click(function(){
        var commentid = $(".delete_report input[name='commentid']").val();
        $.ajax({
            url : "/console/order/report/status/handle",
            type : "post",
            data : {
                "type" : 2,
                "cityid" : cityid,
                "commentid" : commentid
            },
            dataType: "json",
            success:function (data){
                if(data.status == 'success') {
                    alert(data.message);
                    window.location.reload();
                } else {
                    alert(data.message);
                }
            }
        });
    })
    //举报无效
    $(".no_deal_with_sure").click(function(){
        var commentid = $(".no_deal_with input[name='commentid']").val();
        $.ajax({
            url : "/console/order/report/status/handle",
            type : "post",
            data : {
                "type" : 1,
                "cityid" : cityid,
                "commentid" : commentid
            },
            dataType: "json",
            success:function (data){
                if(data.status == 'success') {
                    alert(data.message);
                    window.location.reload();
                } else {
                    alert(data.message);
                }
            }
        });
    })


    function select_date() {
        var startTime = $("input[name='starttime']").val();
        var lastTime = $("input[name='lasttime']").val();
        if(!startTime || !lastTime) {
            alert('请选择开始时间和结束时间'); return;
        }
        window.location.href="/console/order/report/list?cityid=" + cityid+"&starttime="+startTime+"&lasttime="+lastTime;
    }

    $(".user_list_searchbtn").click(function() {
        var search=$("input[name='search']").val();
        if(search == '') {
            return;
        }
        window.location.href = "/console/order/report/list?cityid="+cityid+"&search="+search+"&starttime="+starttime+"&lasttime="+lasttime+"&now=" + Date.parse(new Date());
    });
</script>
@endsection